<?php

namespace common\models\db\tables;

use Yii;

/**
 * This is the model class for table "{{%categories}}".
 *
 * @property int $id
 * @property int|null $pid
 * @property int $is_root 1是2否根分类
 * @property int $root_sort 排序
 * @property string $name 分类名
 * @property int $created_at
 * @property int $updated_at
 * @property int $status 1正常使用
 */
class Categories extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%categories}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['pid', 'is_root', 'root_sort', 'name', 'created_at', 'updated_at', 'status'], 'trim'],
            [['pid', 'is_root', 'root_sort', 'created_at', 'updated_at', 'status'], 'integer'],
            [['name', 'created_at', 'updated_at'], 'required'],
            [['name'], 'string', 'max' => 180],
            [['pid'], 'default', 'value' => null],
            [['is_root'], 'default', 'value' => 2],
            [['root_sort', 'status'], 'default', 'value' => 1],
            [['name'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'pid' => Yii::t('app', 'Pid'),
            'is_root' => Yii::t('app', '1是2否根分类'),
            'root_sort' => Yii::t('app', '排序'),
            'name' => Yii::t('app', '分类名'),
            'created_at' => Yii::t('app', 'Created At'),
            'updated_at' => Yii::t('app', 'Updated At'),
            'status' => Yii::t('app', '1正常使用'),
        ];
    }
}
